package com.seanchenxi.gwt.wordpress.xmlrpc.service.local.impl;

import java.util.ArrayList;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.seanchenxi.gwt.wordpress.domain.model.Category;
import com.seanchenxi.gwt.wordpress.domain.model.FileData;
import com.seanchenxi.gwt.wordpress.domain.model.Post;
import com.seanchenxi.gwt.wordpress.domain.model.PostEditor;
import com.seanchenxi.gwt.wordpress.domain.model.WpFile;
import com.seanchenxi.gwt.wordpress.xmlrpc.service.MetaWeblogLocalServiceAsync;

/**
 * The Class MetaWeblogLocalServiceAsyncImpl.
 */
public class MetaWeblogLocalServiceAsyncImpl extends
		MetaWeblogLocalServiceAsyncWrapper implements
		MetaWeblogLocalServiceAsync {

	/**
	 * Instantiates a new meta weblog local service async impl.
	 * 
	 * @param url
	 *            the xmlrpc's url
	 * @param wpUserName
	 *            the wp user name
	 * @param wpPassword
	 *            the wp password
	 */
	public MetaWeblogLocalServiceAsyncImpl(String url, String wpUserName,
			String wpPassword) {
		super(url, wpUserName, wpPassword);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#newPost
	 * (int, com.seanchenxi.gwt.wordpress.service.model.PostCreator, boolean,
	 * com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void newPost(int blogId, PostEditor postCreator, boolean publish,
			AsyncCallback<Integer> callback) {
		getMetaWeblogServie().newPost(blogId, getWpUserName(), getWpPassword(),
				postCreator, publish, callback);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#editPost
	 * (int, com.seanchenxi.gwt.wordpress.service.model.PostEditor, boolean,
	 * com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void editPost(int postId, PostEditor postEditor, boolean publish,
			AsyncCallback<Boolean> callback) {
		getMetaWeblogServie().editPost(postId, getWpUserName(),
				getWpPassword(), postEditor, publish, callback);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#getPost
	 * (int, com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void getPost(int postId, AsyncCallback<Post> callback) {
		getMetaWeblogServie().getPost(postId, getWpUserName(), getWpPassword(),
				callback);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#
	 * getRecentPosts(int, int, com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void getRecentPosts(int blogId, int number,
			AsyncCallback<ArrayList<Post>> callback) {
		getMetaWeblogServie().getRecentPosts(blogId, getWpUserName(),
				getWpPassword(), number, callback);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#
	 * getCategories(int, com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void getCategories(int blogId,
			AsyncCallback<ArrayList<Category>> callback) {
		getMetaWeblogServie().getCategories(blogId, getWpUserName(),
				getWpPassword(), callback);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#
	 * newMediaObject(int, com.seanchenxi.gwt.wordpress.service.model.FileData,
	 * com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void newMediaObject(int blogId, FileData data,
			AsyncCallback<WpFile> callback) {
		// TODO will implement later
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#getTemplate
	 * (int, com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void getTemplate(int blogId, AsyncCallback<String> callback) {
		getMetaWeblogServie().getTemplate(blogId, getWpUserName(),
				getWpPassword(), callback);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#setTemplate
	 * (int, java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void setTemplate(int blogId, String content,
			AsyncCallback<Boolean> callback) {
		getMetaWeblogServie().setTemplate(blogId, getWpUserName(),
				getWpPassword(), content, callback);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.seanchenxi.gwt.wordpress.service.MetaWeblogLocalServiceAsync#deletePost
	 * (int, com.google.gwt.user.client.rpc.AsyncCallback)
	 */
	@Override
	public void deletePost(int postId, AsyncCallback<Boolean> callback) {
		getMetaWeblogServie().deletePost(postId, getWpUserName(),
				getWpPassword(), callback);
	}

}
